Shader "Alpha/Lightmapped/Bumped Diffuse" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Base (RGB)", 2D) = "white" {}
		_BumpMap ("Bump (RGB)", 2D) = "bump" {}
		_LightMap ("Lightmap (RGB)", 2D) = "black" {}
	}
	SubShader {
		//UsePass "Alpha/Lightmapped/VertexLit/BASE"
		
	ZTest LEqual
	ZWrite On
	Tags {"Queue"="Transparent-1"}

	// Ambient pass
	Pass {
		Name "BASE"
		Blend SrcAlpha OneMinusSrcAlpha
		Tags {"LightMode" = "PixelOrNone"}
		Color [_PPLAmbient]
		
		BindChannels {
			Bind "Vertex", vertex
			Bind "normal", normal
			Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
			Bind "texcoord", texcoord1 // main uses 1st uv
		}
		SetTexture [_LightMap] {
			constantColor [_Color]
			combine texture * constant
		}
		SetTexture [_MainTex] {
			constantColor [_Color]
			combine texture * previous, texture * constant
		}
	}
	
	// Vertex lights
	Pass {
		Name "BASE"
		Blend SrcAlpha OneMinusSrcAlpha
		Tags {"LightMode" = "Vertex"}
		Material {
			Diffuse [_Color]
			Shininess [_Shininess]
			Specular [_SpecColor]
		}

		Lighting On
		SeparateSpecular On

		BindChannels {
			Bind "Vertex", vertex
			Bind "normal", normal
			Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
			Bind "texcoord1", texcoord1 // lightmap uses 2nd uv
			Bind "texcoord", texcoord2 // main uses 1st uv
		}
		
		SetTexture [_LightMap] {
			constantColor [_Color]
			combine texture * constant
		}
		SetTexture [_LightMap] {
			constantColor (0.5,0.5,0.5,0.5)
			combine previous * constant + primary
		}
		SetTexture [_MainTex] {
			combine texture * previous DOUBLE, texture * primary
		}
	}
		UsePass "Alpha/Bumped Diffuse/PPL"
	} 
	FallBack "Alpha/Lightmapped/VertexLit", 1
}